# 顶层Makefile用于构建项目
# 包含设备树overlay、内核驱动和应用程序

# 定义子目录
DRIVER_DIR := src/dirver
APP_DIR := src/app
BUILD_DIR := build

# 默认目标
all: prepare build-dtb build-driver build-app

# 创建输出目录
prepare:
	mkdir -p $(BUILD_DIR)

# 构建内核驱动
build-driver:
	$(MAKE) -C $(DRIVER_DIR)

# 构建应用程序
build-app:
	$(MAKE) -C $(APP_DIR)

# 清理所有构建产物
clean:
	$(MAKE) -C $(DRIVER_DIR) clean
	$(MAKE) -C $(APP_DIR) clean
	rm -f $(BUILD_DIR)/*.ko $(BUILD_DIR)/*.dtbo $(BUILD_DIR)/*app*

.PHONY: all prepare build-dtb build-driver build-app clean
